#include <bits/stdc++.h>
using namespace std;
int ld[10001][2],ru[10001][2];
void f(int id,int a,int b,int g,int k){
    ld[id][0]=a;
    ld[id][1]=b;
    ru[id][0]=a+g;
    ru[id][1]=b+k;
}
int main(){
    int n,a,b,g,k;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a>>b>>g>>k;
        f(i,a,b,g,k);
    }
    int x,y;
    cin>>x>>y;
    for (int i=n;i>0;i--){
        if ((x >= ld[i][0] && x <= ru[i][0]) && (y >= ld[i][1] && y <= ru[i][1])) {
            cout<<i;
            return 0;
        }
    }
    cout<< -1;
    
    return 0;
}